<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!doctype html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta charset="utf-8">
<title>每日新增用户统计</title>
<script src="../static/jquery-1.11.0.js"></script>
<script src="../static/md5.js"></script>
<script src="../static/comm.js"></script>
<link rel="stylesheet" type="text/css" href="../static/jquery-easyui-1.4.4/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="../static/jquery-easyui-1.4.4/themes/icon.css">
<script type="text/javascript" src="../static/jquery-easyui-1.4.4/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../static/jquery-easyui-1.4.4/locale/easyui-lang-zh_CN.js"></script>
<style type="text/css">
.expired {
	color: red;
}

.expireing {
	color: blue;
}

.attentionPlase {
	padding-left: 20px;
	color: red;
	font-size: 20px;
}
</style>
</head>
<body class="easyui-layout">
	<div data-options="region:'center',split:true" style="background-color: #eee; border: 0px; overflow:hidden;">
		<div id="tb" style="padding:3px">
			<span>开始时间:</span>
			<input class="easyui-datebox easyui-datebox2" data-options="showSeconds:true" id="beginTime"></input>
			<span>结束时间:</span>
			<input class="easyui-datebox easyui-datebox2" data-options="showSeconds:true" id="endTime"></input>
			<button class="btn" id="queryBtn" onclick="doSearch()">查 询</button>
			<button class="btn" id="exportBtn" onclick="doExport()">导出excel</button>
			&nbsp;&nbsp;&nbsp;&nbsp;
			&nbsp;&nbsp;导出类型&nbsp;:&nbsp;
			<select id="exportType">
				<option value="1">注册用户</option>
				<option value="2">注册用户(邀请)</option> 
				<option value="3">新增交易用户</option> 
				<option value="4">新增交易用户(邀请)</option>
			</select>
			<button class="btn" id="exportDetailBtn">导出详情</button>
		</div>
		<table id="statistics-table" class="easyui-datagrid" style="width: 100%; height: 95%;" data-options="rownumbers:true,singleSelect:true,url:'../query.htm?listId=SLAVE_WHOLE_USER_ANALYSIS.every_day_register_statistics&isJzh=0',method:'post',pagination:false,rownumbers:true,fitColumns:true">
			<thead>
				<tr>
					<th field="gmt_create">日期</th>
					<th field="total_register_count">注册人数</th>
					<th field="friend_invite_register_count">注册人数(邀请)</th>
					<th field="order_user_count">新增交易用户数</th>
					<th field="friend_invite_trade_count">新增交易用户数(邀请)</th>
				</tr>
			</thead>
		</table>
	</div>
	
	<script type="text/javascript">
		$(function(){
			$('#beginTime').datebox('setValue', '1');
			$('#endTime').datebox('setValue', '1');
		});
		function doSearch(){
			$('#statistics-table').datagrid('load',{
				init:0,
				beginDate: $('#beginTime').datetimebox('getValue'),
				endDate: $('#endTime').datetimebox('getValue')
			});
		}
		function doExport(){
			if (confirm("确定要导出excel吗?")) {
				var listId = "SLAVE_WHOLE_USER_ANALYSIS.export_every_day_register_statistics&isJzh=0";
				var mytime = new Date().toCNString2();
				var beginDate= $('#beginTime').datetimebox('getValue');
				var endDate = $('#endTime').datetimebox('getValue');
				var excelname = "每日注册用户数据统计" + mytime;	
				window.open("../exportexcel.htm?listId=" + listId
						+ "&excelname=" + excelname + "&beginDate="
						+ beginDate + "&endDate=" + endDate
						+ "&init=0");
			}
			
		}
		
		$("#exportDetailBtn").click(function(){
			 if(confirm("确定要导出excel吗?")) {
				 var exportType = $('#exportType').val();
				 var beginDate = $('#beginTime').datetimebox('getValue');
				 var endDate = $('#endTime').datetimebox('getValue');
				 var isInvited = 0;
				 if (exportType && (Number(exportType) == 2 || Number(exportType) == 4)) {
					 isInvited = 1;
				 }
				 
				 var mytime = new Date().toCNString2();
				 if (exportType && Number(exportType) > 2) {
					 var listId = "SLAVE_WHOLE_USER_ANALYSIS.export_order_user_info_increment";
					 var excelname = "新增交易用户详情" + mytime;
					 if (isInvited == 1) {
						 excelname = "新增交易用户详情_邀请" + mytime
					 }
					 window.open("../exportexcel.htm?listId="+ listId +"&excelname="+ excelname
							+"&beginTimeBuy="+ beginDate +"&endTimeBuy="+ endDate
							+"&beginTimeRegist="+ beginDate +"&endTimeRegist="+ endDate
							+"&isInvited=" + isInvited + "&isJzh=0");
				 } else {
					 var myDate = new Date();
					 var listId = "SLAVE_WHOLE_USER_ANALYSIS.export_everyday_regist_user";
					 var excelname = "注册用户详情" + mytime;
					 if (isInvited == 1) {
						 excelname = "注册用户详情_邀请" + mytime
					 }
					 window.open("../exportexcel.htm?listId="+ listId +"&excelname="+ excelname
							+"&beginDate="+ beginDate +"&endDate="+ endDate
							+"&isInvited=" + isInvited);
				 }
			 }
		});
		
	</script>
</body>
</html>
